<!DOCTYPE html>

<html lang="en" data-content_root="./">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>client module &#8212; Eclipse paho-mqtt  documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d1102ebc" />
    <link rel="stylesheet" type="text/css" href="_static/alabaster.css?v=12dfc556" />
    <script src="_static/documentation_options.js?v=5929fcd5"></script>
    <script src="_static/doctools.js?v=9a2dae69"></script>
    <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="helpers" href="helpers.html" />
    <link rel="prev" title="Eclipse Paho™ MQTT Python Client" href="index.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  

  
  

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <section id="client-module">
<h1>client module<a class="headerlink" href="#client-module" title="Link to this heading">¶</a></h1>
<p id="module-paho.mqtt.client">This is an MQTT client module. MQTT is a lightweight pub/sub messaging
protocol that is easy to implement and suitable for low powered devices.</p>
<dl class="py class">
<dt class="sig sig-object py" id="paho.mqtt.client.Client">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">Client</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callback_api_version</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.enums.CallbackAPIVersion" title="paho.mqtt.enums.CallbackAPIVersion"><span class="pre">CallbackAPIVersion</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">CallbackAPIVersion.VERSION1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">client_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clean_session</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">userdata</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">protocol</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTProtocolVersion" title="paho.mqtt.enums.MQTTProtocolVersion"><span class="pre">MQTTProtocolVersion</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">MQTTProtocolVersion.MQTTv311</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transport</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'tcp'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'websockets'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'unix'</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'tcp'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">reconnect_on_failure</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">manual_ack</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paho.mqtt.client.Client" title="Link to this definition">¶</a></dt>
<dd><p>MQTT version 3.1/3.1.1/5.0 client class.</p>
<p>This is the main class for use communicating with an MQTT broker.</p>
<p>General usage flow:</p>
<ul class="simple">
<li><p>Use <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.connect_async" title="paho.mqtt.client.Client.connect_async"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_async()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.connect_srv" title="paho.mqtt.client.Client.connect_srv"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_srv()</span></code></a> to connect to a broker</p></li>
<li><p>Use <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> to set a thread running to call <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> for you.</p></li>
<li><p>Or use <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a> to handle calling <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> for you in a blocking function.</p></li>
<li><p>Or call <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> frequently to maintain network traffic flow with the broker</p></li>
<li><p>Use <a class="reference internal" href="#paho.mqtt.client.Client.subscribe" title="paho.mqtt.client.Client.subscribe"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">subscribe()</span></code></a> to subscribe to a topic and receive messages</p></li>
<li><p>Use <a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a> to send messages</p></li>
<li><p>Use <a class="reference internal" href="#paho.mqtt.client.Client.disconnect" title="paho.mqtt.client.Client.disconnect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">disconnect()</span></code></a> to disconnect from the broker</p></li>
</ul>
<p>Data returned from the broker is made available with the use of callback
functions as described below.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>callback_api_version</strong> (<a class="reference internal" href="types.html#paho.mqtt.enums.CallbackAPIVersion" title="paho.mqtt.enums.CallbackAPIVersion"><em>CallbackAPIVersion</em></a>) – define the API version for user-callback (on_connect, on_publish,…).
This field is required and it’s recommended to use the latest version (CallbackAPIVersion.API_VERSION2).
See each callback for description of API for each version. The file docs/migrations.rst contains details on
how to migrate between version.</p></li>
<li><p><strong>client_id</strong> (<em>str</em>) – the unique client id string used when connecting to the
broker. If client_id is zero length or None, then the behaviour is
defined by which protocol version is in use. If using MQTT v3.1.1, then
a zero length client id will be sent to the broker and the broker will
generate a random for the client. If using MQTT v3.1 then an id will be
randomly generated. In both cases, clean_session must be True. If this
is not the case a ValueError will be raised.</p></li>
<li><p><strong>clean_session</strong> (<em>bool</em>) – a boolean that determines the client type. If True,
the broker will remove all information about this client when it
disconnects. If False, the client is a persistent client and
subscription information and queued messages will be retained when the
client disconnects.
Note that a client will never discard its own outgoing messages on
disconnect. Calling connect() or reconnect() will cause the messages to
be resent.  Use reinitialise() to reset a client to its original state.
The clean_session argument only applies to MQTT versions v3.1.1 and v3.1.
It is not accepted if the MQTT version is v5.0 - use the clean_start
argument on connect() instead.</p></li>
<li><p><strong>userdata</strong> – user defined data of any type that is passed as the “userdata”
parameter to callbacks. It may be updated at a later point with the
user_data_set() function.</p></li>
<li><p><strong>protocol</strong> (<em>int</em>) – allows explicit setting of the MQTT version to
use for this client. Can be paho.mqtt.client.MQTTv311 (v3.1.1),
paho.mqtt.client.MQTTv31 (v3.1) or paho.mqtt.client.MQTTv5 (v5.0),
with the default being v3.1.1.</p></li>
<li><p><strong>transport</strong> – use “websockets” to use WebSockets as the transport
mechanism. Set to “tcp” to use raw TCP, which is the default.
Use “unix” to use Unix sockets as the transport mechanism; note that
this option is only available on platforms that support Unix sockets,
and the “host” argument is interpreted as the path to the Unix socket
file in this case.</p></li>
<li><p><strong>manual_ack</strong> (<em>bool</em>) – normally, when a message is received, the library automatically
acknowledges after on_message callback returns.  manual_ack=True allows the application to
acknowledge receipt after it has completed processing of a message
using a the ack() method. This addresses vulnerability to message loss
if applications fails while processing a message, or while it pending
locally.</p></li>
</ul>
</dd>
</dl>
<section id="callbacks">
<h2>Callbacks<a class="headerlink" href="#callbacks" title="Link to this heading">¶</a></h2>
<p>A number of callback functions are available to receive data back from the
broker. To use a callback, define a function and then assign it to the
client:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">on_connect</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">):</span>
    <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Connected with result code </span><span class="si">{</span><span class="n">reason_code</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>

<span class="n">client</span><span class="o">.</span><span class="n">on_connect</span> <span class="o">=</span> <span class="n">on_connect</span>
</pre></div>
</div>
<p>Callbacks can also be attached using decorators:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mqttc</span> <span class="o">=</span> <span class="n">paho</span><span class="o">.</span><span class="n">mqtt</span><span class="o">.</span><span class="n">Client</span><span class="p">()</span>

<span class="nd">@mqttc</span><span class="o">.</span><span class="n">connect_callback</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">on_connect</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">):</span>
    <span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">&quot;Connected with result code </span><span class="si">{</span><span class="n">reason_code</span><span class="si">}</span><span class="s2">&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>All of the callbacks as described below have a “client” and an “userdata”
argument. “client” is the <a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Client</span></code></a> instance that is calling the callback.
userdata” is user data of any type and can be set when creating a new client
instance or with <a class="reference internal" href="#paho.mqtt.client.Client.user_data_set" title="paho.mqtt.client.Client.user_data_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">user_data_set()</span></code></a>.</p>
<p>If you wish to suppress exceptions within a callback, you should set
<code class="docutils literal notranslate"><span class="pre">mqttc.suppress_exceptions</span> <span class="pre">=</span> <span class="pre">True</span></code></p>
<p>The callbacks are listed below, documentation for each of them can be found
at the same function name:</p>
<p><a class="reference internal" href="#paho.mqtt.client.Client.on_connect" title="paho.mqtt.client.Client.on_connect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_connect</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_connect_fail" title="paho.mqtt.client.Client.on_connect_fail"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_connect_fail</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_disconnect" title="paho.mqtt.client.Client.on_disconnect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_disconnect</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_message" title="paho.mqtt.client.Client.on_message"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_message</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_publish" title="paho.mqtt.client.Client.on_publish"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_publish</span></code></a>,
<a class="reference internal" href="#paho.mqtt.client.Client.on_subscribe" title="paho.mqtt.client.Client.on_subscribe"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_subscribe</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_unsubscribe" title="paho.mqtt.client.Client.on_unsubscribe"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_unsubscribe</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_log" title="paho.mqtt.client.Client.on_log"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_log</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_socket_open" title="paho.mqtt.client.Client.on_socket_open"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_socket_open</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_socket_close" title="paho.mqtt.client.Client.on_socket_close"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_socket_close</span></code></a>,
<a class="reference internal" href="#paho.mqtt.client.Client.on_socket_register_write" title="paho.mqtt.client.Client.on_socket_register_write"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_socket_register_write</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_socket_unregister_write" title="paho.mqtt.client.Client.on_socket_unregister_write"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_socket_unregister_write</span></code></a></p>
<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.ack">
<span class="sig-name descname"><span class="pre">ack</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mid</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.ack" title="Link to this definition">¶</a></dt>
<dd><p>send an acknowledgement for a given message id (stored in <a class="reference internal" href="#paho.mqtt.client.MQTTMessage.mid" title="paho.mqtt.client.MQTTMessage.mid"><code class="xref py py-attr docutils literal notranslate"><span class="pre">message.mid</span></code></a>).
only useful in QoS&gt;=1 and <code class="docutils literal notranslate"><span class="pre">manual_ack=True</span></code> (option of <a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Client</span></code></a>)</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.callback_api_version">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">callback_api_version</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.enums.CallbackAPIVersion" title="paho.mqtt.enums.CallbackAPIVersion"><span class="pre">CallbackAPIVersion</span></a></em><a class="headerlink" href="#paho.mqtt.client.Client.callback_api_version" title="Link to this definition">¶</a></dt>
<dd><p>Return the callback API version used for user-callback. See docstring for
each user-callback (<a class="reference internal" href="#paho.mqtt.client.Client.on_connect" title="paho.mqtt.client.Client.on_connect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_connect</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.on_publish" title="paho.mqtt.client.Client.on_publish"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_publish</span></code></a>, …) for details.</p>
<p>This property is read-only.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.connect">
<span class="sig-name descname"><span class="pre">connect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">host</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1883</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keepalive</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">60</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_address</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clean_start</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="m"><span class="pre">3</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.connect" title="Link to this definition">¶</a></dt>
<dd><p>Connect to a remote broker. This is a blocking call that establishes
the underlying connection and transmits a CONNECT packet.
Note that the connection status will not be updated until a CONNACK is received and
processed (this requires a running network loop, see <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop</span></code></a>…).</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>host</strong> (<em>str</em>) – the hostname or IP address of the remote broker.</p></li>
<li><p><strong>port</strong> (<em>int</em>) – the network port of the server host to connect to. Defaults to
1883. Note that the default port for MQTT over SSL/TLS is 8883 so if you
are using <a class="reference internal" href="#paho.mqtt.client.Client.tls_set" title="paho.mqtt.client.Client.tls_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">tls_set()</span></code></a> the port may need providing.</p></li>
<li><p><strong>keepalive</strong> (<em>int</em>) – Maximum period in seconds between communications with the
broker. If no other messages are being exchanged, this controls the
rate at which the client will send ping messages to the broker.</p></li>
<li><p><strong>clean_start</strong> (<em>bool</em>) – (MQTT v5.0 only) True, False or MQTT_CLEAN_START_FIRST_ONLY.
Sets the MQTT v5.0 clean_start flag always, never or on the first successful connect only,
respectively.  MQTT session data (such as outstanding messages and subscriptions)
is cleared on successful connect when the clean_start flag is set.
For MQTT v3.1.1, the <code class="docutils literal notranslate"><span class="pre">clean_session</span></code> argument of <a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Client</span></code></a> should be used for similar
result.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – (MQTT v5.0 only) the MQTT v5.0 properties to be sent in the
MQTT connect packet.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.connect_async">
<span class="sig-name descname"><span class="pre">connect_async</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">host</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1883</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keepalive</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">60</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_address</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clean_start</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="m"><span class="pre">3</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.connect_async" title="Link to this definition">¶</a></dt>
<dd><p>Connect to a remote broker asynchronously. This is a non-blocking
connect call that can be used with <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> to provide very quick
start.</p>
<p>Any already established connection will be terminated immediately.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>host</strong> (<em>str</em>) – the hostname or IP address of the remote broker.</p></li>
<li><p><strong>port</strong> (<em>int</em>) – the network port of the server host to connect to. Defaults to
1883. Note that the default port for MQTT over SSL/TLS is 8883 so if you
are using <a class="reference internal" href="#paho.mqtt.client.Client.tls_set" title="paho.mqtt.client.Client.tls_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">tls_set()</span></code></a> the port may need providing.</p></li>
<li><p><strong>keepalive</strong> (<em>int</em>) – Maximum period in seconds between communications with the
broker. If no other messages are being exchanged, this controls the
rate at which the client will send ping messages to the broker.</p></li>
<li><p><strong>clean_start</strong> (<em>bool</em>) – (MQTT v5.0 only) True, False or MQTT_CLEAN_START_FIRST_ONLY.
Sets the MQTT v5.0 clean_start flag always, never or on the first successful connect only,
respectively.  MQTT session data (such as outstanding messages and subscriptions)
is cleared on successful connect when the clean_start flag is set.
For MQTT v3.1.1, the <code class="docutils literal notranslate"><span class="pre">clean_session</span></code> argument of <a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Client</span></code></a> should be used for similar
result.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – (MQTT v5.0 only) the MQTT v5.0 properties to be sent in the
MQTT connect packet.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.connect_srv">
<span class="sig-name descname"><span class="pre">connect_srv</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">domain</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keepalive</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">60</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_address</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">bind_port</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clean_start</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="m"><span class="pre">3</span></span><span class="p"><span class="pre">]</span></span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">3</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.connect_srv" title="Link to this definition">¶</a></dt>
<dd><p>Connect to a remote broker.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>domain</strong> (<em>str</em>) – the DNS domain to search for SRV records; if None,
try to determine local domain name.</p></li>
<li><p><strong>properties</strong> (<em>keepalive</em><em>, </em><em>bind_address</em><em>, </em><em>clean_start and</em>) – see <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a></p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.connect_timeout">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">connect_timeout</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">float</span></em><a class="headerlink" href="#paho.mqtt.client.Client.connect_timeout" title="Link to this definition">¶</a></dt>
<dd><p>Connection establishment timeout in seconds.</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.disable_logger">
<span class="sig-name descname"><span class="pre">disable_logger</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.disable_logger" title="Link to this definition">¶</a></dt>
<dd><p>Disable logging using standard python logging package. This has no effect on the <a class="reference internal" href="#paho.mqtt.client.Client.on_log" title="paho.mqtt.client.Client.on_log"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_log</span></code></a> callback.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.disconnect">
<span class="sig-name descname"><span class="pre">disconnect</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">reasoncode</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.disconnect" title="Link to this definition">¶</a></dt>
<dd><p>Disconnect a connected client from the broker.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>reasoncode</strong> (<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a>) – (MQTT v5.0 only) a ReasonCode instance setting the MQTT v5.0
reasoncode to be sent with the disconnect packet. It is optional, the receiver
then assuming that 0 (success) is the value.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – (MQTT v5.0 only) a Properties instance setting the MQTT v5.0 properties
to be included. Optional - if not set, no properties are sent.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.enable_bridge_mode">
<span class="sig-name descname"><span class="pre">enable_bridge_mode</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.enable_bridge_mode" title="Link to this definition">¶</a></dt>
<dd><p>Sets the client in a bridge mode instead of client mode.</p>
<p>Must be called before <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a> to have any effect.
Requires brokers that support bridge mode.</p>
<p>Under bridge mode, the broker will identify the client as a bridge and
not send it’s own messages back to it. Hence a subsciption of # is
possible without message loops. This feature also correctly propagates
the retain flag on the messages.</p>
<p>Currently Mosquitto and RSMB support this feature. This feature can
be used to create a bridge between multiple broker.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.enable_logger">
<span class="sig-name descname"><span class="pre">enable_logger</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">logger</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Logger</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.enable_logger" title="Link to this definition">¶</a></dt>
<dd><p>Enables a logger to send log messages to</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>logger</strong> (<em>logging.Logger</em>) – if specified, that <code class="docutils literal notranslate"><span class="pre">logging.Logger</span></code> object will be used, otherwise
one will be created automatically.</p>
</dd>
</dl>
<p>See <a class="reference internal" href="#paho.mqtt.client.Client.disable_logger" title="paho.mqtt.client.Client.disable_logger"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">disable_logger</span></code></a> to undo this action.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.host">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">host</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><a class="headerlink" href="#paho.mqtt.client.Client.host" title="Link to this definition">¶</a></dt>
<dd><p>Host to connect to. If <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a> hasn’t been called yet, returns an empty string.</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.is_connected">
<span class="sig-name descname"><span class="pre">is_connected</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.is_connected" title="Link to this definition">¶</a></dt>
<dd><p>Returns the current status of the connection</p>
<p>True if connection exists
False if connection is closed</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.keepalive">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">keepalive</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#paho.mqtt.client.Client.keepalive" title="Link to this definition">¶</a></dt>
<dd><p>Client keepalive interval (in seconds).</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.logger">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">logger</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Logger</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.logger" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop">
<span class="sig-name descname"><span class="pre">loop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1.0</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop" title="Link to this definition">¶</a></dt>
<dd><p>Process network events.</p>
<p>It is strongly recommended that you use <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a>, or
<a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a>, or if you are using an external event loop using
<a class="reference internal" href="#paho.mqtt.client.Client.loop_read" title="paho.mqtt.client.Client.loop_read"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_read()</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.loop_write" title="paho.mqtt.client.Client.loop_write"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_write()</span></code></a>, and <a class="reference internal" href="#paho.mqtt.client.Client.loop_misc" title="paho.mqtt.client.Client.loop_misc"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_misc()</span></code></a>. Using loop() on it’s own is
no longer recommended.</p>
<p>This function must be called regularly to ensure communication with the
broker is carried out. It calls select() on the network socket to wait
for network events. If incoming data is present it will then be
processed. Outgoing commands, from e.g. <a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a>, are normally sent
immediately that their function is called, but this is not always
possible. loop() will also attempt to send any remaining outgoing
messages, which also includes commands that are part of the flow for
messages with QoS&gt;0.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>timeout</strong> (<em>int</em>) – The time in seconds to wait for incoming/outgoing network
traffic before timing out and returning.</p>
</dd>
</dl>
<p>Returns MQTT_ERR_SUCCESS on success.
Returns &gt;0 on error.</p>
<p>A ValueError will be raised if timeout &lt; 0</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_forever">
<span class="sig-name descname"><span class="pre">loop_forever</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">retry_first_connection</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_forever" title="Link to this definition">¶</a></dt>
<dd><p>This function calls the network loop functions for you in an
infinite blocking loop. It is useful for the case where you only want
to run the MQTT client loop in your program.</p>
<p>loop_forever() will handle reconnecting for you if reconnect_on_failure is
true (this is the default behavior). If you call <a class="reference internal" href="#paho.mqtt.client.Client.disconnect" title="paho.mqtt.client.Client.disconnect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">disconnect()</span></code></a> in a callback
it will return.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>timeout</strong> (<em>int</em>) – The time in seconds to wait for incoming/outgoing network
traffic before timing out and returning.</p></li>
<li><p><strong>retry_first_connection</strong> (<em>bool</em>) – Should the first connection attempt be retried on failure.
This is independent of the reconnect_on_failure setting.</p></li>
</ul>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>OSError</strong> – if the first connection fail unless retry_first_connection=True</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_misc">
<span class="sig-name descname"><span class="pre">loop_misc</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_misc" title="Link to this definition">¶</a></dt>
<dd><p>Process miscellaneous network events. Use in place of calling <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> if you
wish to call select() or equivalent on.</p>
<p>Do not use if you are using <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_read">
<span class="sig-name descname"><span class="pre">loop_read</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">max_packets</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_read" title="Link to this definition">¶</a></dt>
<dd><p>Process read network events. Use in place of calling <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> if you
wish to handle your client reads as part of your own application.</p>
<p>Use <a class="reference internal" href="#paho.mqtt.client.Client.socket" title="paho.mqtt.client.Client.socket"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">socket()</span></code></a> to obtain the client socket to call select() or equivalent
on.</p>
<p>Do not use if you are using <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_start">
<span class="sig-name descname"><span class="pre">loop_start</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_start" title="Link to this definition">¶</a></dt>
<dd><p>This is part of the threaded client interface. Call this once to
start a new thread to process network traffic. This provides an
alternative to repeatedly calling <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> yourself.</p>
<p>Under the hood, this will call <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever</span></code></a> in a thread, which means that
the thread will terminate if you call <a class="reference internal" href="#paho.mqtt.client.Client.disconnect" title="paho.mqtt.client.Client.disconnect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">disconnect()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_stop">
<span class="sig-name descname"><span class="pre">loop_stop</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_stop" title="Link to this definition">¶</a></dt>
<dd><p>This is part of the threaded client interface. Call this once to
stop the network thread previously created with <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a>. This call
will block until the network thread finishes.</p>
<p>This don’t guarantee that publish packet are sent, use <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish" title="paho.mqtt.client.MQTTMessageInfo.wait_for_publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">wait_for_publish</span></code></a> or
<a class="reference internal" href="#paho.mqtt.client.Client.on_publish" title="paho.mqtt.client.Client.on_publish"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_publish</span></code></a> to ensure <a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish</span></code></a> are sent.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.loop_write">
<span class="sig-name descname"><span class="pre">loop_write</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.loop_write" title="Link to this definition">¶</a></dt>
<dd><p>Process write network events. Use in place of calling <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a> if you
wish to handle your client writes as part of your own application.</p>
<p>Use <a class="reference internal" href="#paho.mqtt.client.Client.socket" title="paho.mqtt.client.Client.socket"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">socket()</span></code></a> to obtain the client socket to call select() or equivalent
on.</p>
<p>Use <a class="reference internal" href="#paho.mqtt.client.Client.want_write" title="paho.mqtt.client.Client.want_write"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">want_write()</span></code></a> to determine if there is data waiting to be written.</p>
<p>Do not use if you are using <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.manual_ack_set">
<span class="sig-name descname"><span class="pre">manual_ack_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">on</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.manual_ack_set" title="Link to this definition">¶</a></dt>
<dd><p>The paho library normally acknowledges messages as soon as they are delivered to the caller.
If manual_ack is turned on, then the caller MUST manually acknowledge every message once
application processing is complete using <a class="reference internal" href="#paho.mqtt.client.Client.ack" title="paho.mqtt.client.Client.ack"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">ack()</span></code></a></p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.max_inflight_messages">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">max_inflight_messages</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#paho.mqtt.client.Client.max_inflight_messages" title="Link to this definition">¶</a></dt>
<dd><p>Maximum number of messages with QoS &gt; 0 that can be partway through the network flow at once</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.max_inflight_messages_set">
<span class="sig-name descname"><span class="pre">max_inflight_messages_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">inflight</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.max_inflight_messages_set" title="Link to this definition">¶</a></dt>
<dd><p>Set the maximum number of messages with QoS&gt;0 that can be part way
through their network flow at once. Defaults to 20.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.max_queued_messages">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">max_queued_messages</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#paho.mqtt.client.Client.max_queued_messages" title="Link to this definition">¶</a></dt>
<dd><p>Maximum number of message in the outgoing message queue, 0 means unlimited</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.max_queued_messages_set">
<span class="sig-name descname"><span class="pre">max_queued_messages_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">queue_size</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.max_queued_messages_set" title="Link to this definition">¶</a></dt>
<dd><p>Set the maximum number of messages in the outgoing message queue.
0 means unlimited.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.message_callback_add">
<span class="sig-name descname"><span class="pre">message_callback_add</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sub</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="#paho.mqtt.client.MQTTMessage" title="paho.mqtt.client.MQTTMessage"><span class="pre">MQTTMessage</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.message_callback_add" title="Link to this definition">¶</a></dt>
<dd><p>Register a message callback for a specific topic.
Messages that match ‘sub’ will be passed to ‘callback’. Any
non-matching messages will be passed to the default <a class="reference internal" href="#paho.mqtt.client.Client.on_message" title="paho.mqtt.client.Client.on_message"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_message</span></code></a>
callback.</p>
<p>Call multiple times with different ‘sub’ to define multiple topic
specific callbacks.</p>
<p>Topic specific callbacks may be removed with
<a class="reference internal" href="#paho.mqtt.client.Client.message_callback_remove" title="paho.mqtt.client.Client.message_callback_remove"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">message_callback_remove()</span></code></a>.</p>
<p>See <a class="reference internal" href="#paho.mqtt.client.Client.on_message" title="paho.mqtt.client.Client.on_message"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_message</span></code></a> for the expected signature of the callback.</p>
<dl class="simple">
<dt>Decorator: &#64;client.topic_callback(sub) (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@client</span><span class="o">.</span><span class="n">topic_callback</span><span class="p">(</span><span class="s2">&quot;mytopic/#&quot;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">handle_mytopic</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
    <span class="o">...</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.message_callback_remove">
<span class="sig-name descname"><span class="pre">message_callback_remove</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sub</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.message_callback_remove" title="Link to this definition">¶</a></dt>
<dd><p>Remove a message callback previously registered with
<a class="reference internal" href="#paho.mqtt.client.Client.message_callback_add" title="paho.mqtt.client.Client.message_callback_add"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">message_callback_add()</span></code></a>.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_connect">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_connect</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="#paho.mqtt.client.ConnectFlags" title="paho.mqtt.client.ConnectFlags"><span class="pre">ConnectFlags</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_connect" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the broker reponds to our connection request.</p>
<p>Expected signature for callback API version 2:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">connect_flags</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
<dl>
<dt>Expected signature for callback API version 1 change with MQTT protocol version:</dt><dd><ul>
<li><p>For MQTT v3.1 and v3.1.1 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">rc</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>For MQTT v5.0 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">flags</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>connect_flags</strong> (<a class="reference internal" href="#paho.mqtt.client.ConnectFlags" title="paho.mqtt.client.ConnectFlags"><em>ConnectFlags</em></a>) – the flags for this connection</p></li>
<li><p><strong>reason_code</strong> (<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a>) – the connection reason code received from the broken.
In MQTT v5.0 it’s the reason code defined by the standard.
In MQTT v3, we convert return code to a reason code, see
<a class="reference internal" href="#paho.mqtt.client.convert_connack_rc_to_reason_code" title="paho.mqtt.client.convert_connack_rc_to_reason_code"><code class="xref any py py-func docutils literal notranslate"><span class="pre">convert_connack_rc_to_reason_code()</span></code></a>.
<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><code class="xref any py py-class docutils literal notranslate"><span class="pre">ReasonCode</span></code></a> may be compared to integer.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – the MQTT v5.0 properties received from the broker.
For MQTT v3.1 and v3.1.1 properties is not provided and an empty Properties
object is always used.</p></li>
<li><p><strong>flags</strong> (<em>dict</em>) – response flags sent by the broker</p></li>
<li><p><strong>rc</strong> (<em>int</em>) – the connection result, should have a value of <a class="reference internal" href="types.html#paho.mqtt.enums.ConnackCode" title="paho.mqtt.enums.ConnackCode"><code class="xref any py py-class docutils literal notranslate"><span class="pre">ConnackCode</span></code></a></p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>flags is a dict that contains response flags from the broker:</dt><dd><dl class="simple">
<dt>flags[‘session present’] - this flag is useful for clients that are</dt><dd><p>using clean session set to 0 only. If a client with clean
session=0, that reconnects to a broker that it has previously
connected to, this flag indicates whether the broker still has the
session information for the client. If 1, the session still exists.</p>
</dd>
</dl>
</dd>
<dt>The value of rc indicates success or not:</dt><dd><ul class="simple">
<li><p>0: Connection successful</p></li>
<li><p>1: Connection refused - incorrect protocol version</p></li>
<li><p>2: Connection refused - invalid client identifier</p></li>
<li><p>3: Connection refused - server unavailable</p></li>
<li><p>4: Connection refused - bad username or password</p></li>
<li><p>5: Connection refused - not authorised</p></li>
<li><p>6-255: Currently unused.</p></li>
</ul>
</dd>
<dt>Decorator: &#64;client.connect_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_connect_fail">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_connect_fail</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_connect_fail" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the client failed to connect
to the broker.</p>
<p>Expected signature is (for all callback_api_version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connect_fail_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p>
</dd>
<dt class="field-even">Parama userdata<span class="colon">:</span></dt>
<dd class="field-even"><p>the private user data as set in Client() or user_data_set()</p>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.connect_fail_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_disconnect">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_disconnect</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="#paho.mqtt.client.DisconnectFlags" title="paho.mqtt.client.DisconnectFlags"><span class="pre">DisconnectFlags</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_disconnect" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the client disconnects from the broker.</p>
<p>Expected signature for callback API version 2:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">disconnect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">disconnect_flags</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
<dl>
<dt>Expected signature for callback API version 1 change with MQTT protocol version:</dt><dd><ul>
<li><p>For MQTT v3.1 and v3.1.1 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">disconnect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">rc</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>For MQTT v5.0 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">disconnect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>disconnect_flags</strong> (<em>DisconnectFlag</em>) – the flags for this disconnection.</p></li>
<li><p><strong>reason_code</strong> (<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a>) – the disconnection reason code possibly received from the broker (see disconnect_flags).
In MQTT v5.0 it’s the reason code defined by the standard.
In MQTT v3 it’s never received from the broker, we convert an MQTTErrorCode,
see <a class="reference internal" href="#paho.mqtt.client.convert_disconnect_error_code_to_reason_code" title="paho.mqtt.client.convert_disconnect_error_code_to_reason_code"><code class="xref any py py-func docutils literal notranslate"><span class="pre">convert_disconnect_error_code_to_reason_code()</span></code></a>.
<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><code class="xref any py py-class docutils literal notranslate"><span class="pre">ReasonCode</span></code></a> may be compared to integer.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – the MQTT v5.0 properties received from the broker.
For MQTT v3.1 and v3.1.1 properties is not provided and an empty Properties
object is always used.</p></li>
<li><p><strong>rc</strong> (<em>int</em>) – the disconnection result
The rc parameter indicates the disconnection state. If
MQTT_ERR_SUCCESS (0), the callback was called in response to
a disconnect() call. If any other value the disconnection
was unexpected, such as might be caused by a network error.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.disconnect_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_log">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_log</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_log" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the client has log information.
Defined to allow debugging.</p>
<p>Expected signature is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">log_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">level</span><span class="p">,</span> <span class="n">buf</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>level</strong> (<em>int</em>) – gives the severity of the message and will be one of
MQTT_LOG_INFO, MQTT_LOG_NOTICE, MQTT_LOG_WARNING,
MQTT_LOG_ERR, and MQTT_LOG_DEBUG.</p></li>
<li><p><strong>buf</strong> (<em>str</em>) – the message itself</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.log_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_message">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_message</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="#paho.mqtt.client.MQTTMessage" title="paho.mqtt.client.MQTTMessage"><span class="pre">MQTTMessage</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_message" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when a message has been received on a topic
that the client subscribes to.</p>
<p>This callback will be called for every message received unless a
<a class="reference internal" href="#paho.mqtt.client.Client.message_callback_add" title="paho.mqtt.client.Client.message_callback_add"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">message_callback_add()</span></code></a> matched the message.</p>
<dl class="simple">
<dt>Expected signature is (for all callback API version):</dt><dd><p>message_callback(client, userdata, message)</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>message</strong> (<a class="reference internal" href="#paho.mqtt.client.MQTTMessage" title="paho.mqtt.client.MQTTMessage"><em>MQTTMessage</em></a>) – the received message.
This is a class with members topic, payload, qos, retain.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.message_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_pre_connect">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_pre_connect</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_pre_connect" title="Link to this definition">¶</a></dt>
<dd><p>The callback called immediately prior to the connection is made
request.</p>
<p>Expected signature (for all callback API version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connect_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parama Client client<span class="colon">:</span></dt>
<dd class="field-odd"><p>the client instance for this callback</p>
</dd>
<dt class="field-even">Parama userdata<span class="colon">:</span></dt>
<dd class="field-even"><p>the private user data as set in Client() or user_data_set()</p>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.pre_connect_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_publish">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_publish</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_publish" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when a message that was to be sent using the
<a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a> call has completed transmission to the broker.</p>
<p>For messages with QoS levels 1 and 2, this means that the appropriate
handshakes have completed. For QoS 0, this simply means that the message
has left the client.
This callback is important because even if the <a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a> call returns
success, it does not always mean that the message has been sent.</p>
<p>See also <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish" title="paho.mqtt.client.MQTTMessageInfo.wait_for_publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">wait_for_publish</span></code></a> which could be simpler to use.</p>
<p>Expected signature for callback API version 2:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">publish_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">reason_code</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
<p>Expected signature for callback API version 1:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">publish_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>mid</strong> (<em>int</em>) – matches the mid variable returned from the corresponding
<a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">publish()</span></code></a> call, to allow outgoing messages to be tracked.</p></li>
<li><p><strong>reason_code</strong> (<a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a>) – the connection reason code received from the broken.
In MQTT v5.0 it’s the reason code defined by the standard.
In MQTT v3 it’s always the reason code Success</p></li>
</ul>
</dd>
<dt class="field-even">Parama Properties properties<span class="colon">:</span></dt>
<dd class="field-even"><p>the MQTT v5.0 properties received from the broker.
For MQTT v3.1 and v3.1.1 properties is not provided and an empty Properties
object is always used.</p>
</dd>
</dl>
<p>Note: for QoS = 0, the reason_code and the properties don’t really exist, it’s the client
library that generate them. It’s always an empty properties and a success reason code.
Because the (MQTTv5) standard don’t have reason code for PUBLISH packet, the library create them
at PUBACK packet, as if the message was sent with QoS = 1.</p>
<dl class="simple">
<dt>Decorator: &#64;client.publish_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_socket_close">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_socket_close</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">CallbackOnSocket</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_socket_close" title="Link to this definition">¶</a></dt>
<dd><p>The callback called just before the socket is closed.</p>
<p>This should be used to unregister the socket from an external event loop for reading.</p>
<p>Expected signature is (for all callback API version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">socket_close_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">socket</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>sock</strong> (<em>SocketLike</em>) – the socket which is about to be closed.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.socket_close_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_socket_open">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_socket_open</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">CallbackOnSocket</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_socket_open" title="Link to this definition">¶</a></dt>
<dd><p>The callback called just after the socket was opend.</p>
<p>This should be used to register the socket to an external event loop for reading.</p>
<p>Expected signature is (for all callback API version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">socket_open_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">socket</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>sock</strong> (<em>SocketLike</em>) – the socket which was just opened.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.socket_open_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_socket_register_write">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_socket_register_write</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">CallbackOnSocket</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_socket_register_write" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the socket needs writing but can’t.</p>
<p>This should be used to register the socket with an external event loop for writing.</p>
<p>Expected signature is (for all callback API version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">socket_register_write_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">socket</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>sock</strong> (<em>SocketLike</em>) – the socket which should be registered for writing</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.socket_register_write_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_socket_unregister_write">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_socket_unregister_write</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">CallbackOnSocket</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_socket_unregister_write" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the socket doesn’t need writing anymore.</p>
<p>This should be used to unregister the socket from an external event loop for writing.</p>
<p>Expected signature is (for all callback API version):</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">socket_unregister_write_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">socket</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>sock</strong> (<em>SocketLike</em>) – the socket which should be unregistered for writing</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.socket_unregister_write_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_subscribe">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_subscribe</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_subscribe" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the broker responds to a subscribe
request.</p>
<p>Expected signature for callback API version 2:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">subscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">reason_code_list</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
<dl>
<dt>Expected signature for callback API version 1 change with MQTT protocol version:</dt><dd><ul>
<li><p>For MQTT v3.1 and v3.1.1 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">subscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">granted_qos</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>For MQTT v5.0 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">subscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">reason_code_list</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>mid</strong> (<em>int</em>) – matches the mid variable returned from the corresponding
subscribe() call.</p></li>
<li><p><strong>reason_code_list</strong> (<em>list</em><em>[</em><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a><em>]</em>) – reason codes received from the broker for each subscription.
In MQTT v5.0 it’s the reason code defined by the standard.
In MQTT v3, we convert granted QoS to a reason code.
It’s a list of ReasonCode instances.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – the MQTT v5.0 properties received from the broker.
For MQTT v3.1 and v3.1.1 properties is not provided and an empty Properties
object is always used.</p></li>
<li><p><strong>granted_qos</strong> (<em>list</em><em>[</em><em>int</em><em>]</em>) – list of integers that give the QoS level the broker has
granted for each of the different subscription requests.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.subscribe_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.on_unsubscribe">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">on_unsubscribe</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><span class="pre">Client</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">List</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.on_unsubscribe" title="Link to this definition">¶</a></dt>
<dd><p>The callback called when the broker responds to an unsubscribe
request.</p>
<p>Expected signature for callback API version 2:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unsubscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">reason_code_list</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
</pre></div>
</div>
<dl>
<dt>Expected signature for callback API version 1 change with MQTT protocol version:</dt><dd><ul>
<li><p>For MQTT v3.1 and v3.1.1 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unsubscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">)</span>
</pre></div>
</div>
</li>
<li><p>For MQTT v5.0 it’s:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">unsubscribe_callback</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">userdata</span><span class="p">,</span> <span class="n">mid</span><span class="p">,</span> <span class="n">properties</span><span class="p">,</span> <span class="n">v1_reason_codes</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ul>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>client</strong> (<a class="reference internal" href="#paho.mqtt.client.Client" title="paho.mqtt.client.Client"><em>Client</em></a>) – the client instance for this callback</p></li>
<li><p><strong>userdata</strong> – the private user data as set in Client() or user_data_set()</p></li>
<li><p><strong>mid</strong> – matches the mid variable returned from the corresponding
unsubscribe() call.</p></li>
<li><p><strong>reason_code_list</strong> (<em>list</em><em>[</em><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><em>ReasonCode</em></a><em>]</em>) – reason codes received from the broker for each unsubscription.
In MQTT v5.0 it’s the reason code defined by the standard.
In MQTT v3, there is not equivalent from broken and empty list
is always used.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – the MQTT v5.0 properties received from the broker.
For MQTT v3.1 and v3.1.1 properties is not provided and an empty Properties
object is always used.</p></li>
<li><p><strong>v1_reason_codes</strong> – the MQTT v5.0 reason codes received from the broker for each
unsubscribe topic.  A list of ReasonCode instances OR a single
ReasonCode when we unsubscribe from a single topic.</p></li>
</ul>
</dd>
</dl>
<dl class="simple">
<dt>Decorator: &#64;client.unsubscribe_callback() (<code class="docutils literal notranslate"><span class="pre">client</span></code> is the name of the</dt><dd><p>instance which this callback is being attached to)</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.password">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">password</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.password" title="Link to this definition">¶</a></dt>
<dd><p>The password used to connect to the MQTT broker, or None if no password is used.</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.port">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">port</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">int</span></em><a class="headerlink" href="#paho.mqtt.client.Client.port" title="Link to this definition">¶</a></dt>
<dd><p>Broker TCP port to connect to.</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.protocol">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">protocol</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTProtocolVersion" title="paho.mqtt.enums.MQTTProtocolVersion"><span class="pre">MQTTProtocolVersion</span></a></em><a class="headerlink" href="#paho.mqtt.client.Client.protocol" title="Link to this definition">¶</a></dt>
<dd><p>Protocol version used (MQTT v3, MQTT v3.11, MQTTv5)</p>
<p>This property is read-only.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.proxy_set">
<span class="sig-name descname"><span class="pre">proxy_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">proxy_args</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.proxy_set" title="Link to this definition">¶</a></dt>
<dd><p>Configure proxying of MQTT connection. Enables support for SOCKS or
HTTP proxies.</p>
<p>Proxying is done through the PySocks library. Brief descriptions of the
proxy_args parameters are below; see the PySocks docs for more info.</p>
<p>(Required)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>proxy_type</strong> – One of {socks.HTTP, socks.SOCKS4, or socks.SOCKS5}</p></li>
<li><p><strong>proxy_addr</strong> – IP address or DNS name of proxy server</p></li>
</ul>
</dd>
</dl>
<p>(Optional)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>proxy_port</strong> – (int) port number of the proxy server. If not provided,
the PySocks package default value will be utilized, which differs by proxy_type.</p></li>
<li><p><strong>proxy_rdns</strong> – boolean indicating whether proxy lookup should be performed
remotely (True, default) or locally (False)</p></li>
<li><p><strong>proxy_username</strong> – username for SOCKS5 proxy, or userid for SOCKS4 proxy</p></li>
<li><p><strong>proxy_password</strong> – password for SOCKS5 proxy</p></li>
</ul>
</dd>
</dl>
<p>Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mqttc</span><span class="o">.</span><span class="n">proxy_set</span><span class="p">(</span><span class="n">proxy_type</span><span class="o">=</span><span class="n">socks</span><span class="o">.</span><span class="n">HTTP</span><span class="p">,</span> <span class="n">proxy_addr</span><span class="o">=</span><span class="s1">&#39;1.2.3.4&#39;</span><span class="p">,</span> <span class="n">proxy_port</span><span class="o">=</span><span class="mi">4231</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.publish">
<span class="sig-name descname"><span class="pre">publish</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">payload</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">bytes</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">bytearray</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">retain</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo" title="paho.mqtt.client.MQTTMessageInfo"><span class="pre">MQTTMessageInfo</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.publish" title="Link to this definition">¶</a></dt>
<dd><p>Publish a message on a topic.</p>
<p>This causes a message to be sent to the broker and subsequently from
the broker to any clients subscribing to matching topics.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>topic</strong> (<em>str</em>) – The topic that the message should be published on.</p></li>
<li><p><strong>payload</strong> – The actual message to send. If not given, or set to None a
zero length message will be used. Passing an int or float will result
in the payload being converted to a string representing that number. If
you wish to send a true int/float, use struct.pack() to create the
payload you require.</p></li>
<li><p><strong>qos</strong> (<em>int</em>) – The quality of service level to use.</p></li>
<li><p><strong>retain</strong> (<em>bool</em>) – If set to true, the message will be set as the “last known
good”/retained message for the topic.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – (MQTT v5.0 only) the MQTT v5.0 properties to be included.</p></li>
</ul>
</dd>
</dl>
<p>Returns a <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo" title="paho.mqtt.client.MQTTMessageInfo"><code class="xref any py py-class docutils literal notranslate"><span class="pre">MQTTMessageInfo</span></code></a> class, which can be used to determine whether
the message has been delivered (using <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.is_published" title="paho.mqtt.client.MQTTMessageInfo.is_published"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">is_published()</span></code></a>) or to block
waiting for the message to be delivered (<a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish" title="paho.mqtt.client.MQTTMessageInfo.wait_for_publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">wait_for_publish()</span></code></a>). The
message ID and return code of the publish() call can be found at
<a class="reference internal" href="#paho.mqtt.client.MQTTMessage.mid" title="paho.mqtt.client.MQTTMessage.mid"><code class="xref py py-attr docutils literal notranslate"><span class="pre">info.mid</span></code></a> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">info.rc</span></code>.</p>
<p>For backwards compatibility, the <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo" title="paho.mqtt.client.MQTTMessageInfo"><code class="xref any py py-class docutils literal notranslate"><span class="pre">MQTTMessageInfo</span></code></a> class is iterable so
the old construct of <code class="docutils literal notranslate"><span class="pre">(rc,</span> <span class="pre">mid)</span> <span class="pre">=</span> <span class="pre">client.publish(...)</span></code> is still valid.</p>
<p>rc is MQTT_ERR_SUCCESS to indicate success or MQTT_ERR_NO_CONN if the
client is not currently connected.  mid is the message ID for the
publish request. The mid value can be used to track the publish request
by checking against the mid argument in the on_publish() callback if it
is defined.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ValueError</strong> – if topic is None, has zero length or is
invalid (contains a wildcard), except if the MQTT version used is v5.0.
For v5.0, a zero length topic can be used when a Topic Alias has been set.</p></li>
<li><p><strong>ValueError</strong> – if qos is not one of 0, 1 or 2</p></li>
<li><p><strong>ValueError</strong> – if the length of the payload is greater than 268435455 bytes.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.reconnect">
<span class="sig-name descname"><span class="pre">reconnect</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.Client.reconnect" title="Link to this definition">¶</a></dt>
<dd><p>Reconnect the client after a disconnect. Can only be called after
connect()/connect_async().</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.reconnect_delay_set">
<span class="sig-name descname"><span class="pre">reconnect_delay_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">min_delay</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_delay</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">120</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.reconnect_delay_set" title="Link to this definition">¶</a></dt>
<dd><p>Configure the exponential reconnect delay</p>
<p>When connection is lost, wait initially min_delay seconds and
double this time every attempt. The wait is capped at max_delay.
Once the client is fully connected (e.g. not only TCP socket, but
received a success CONNACK), the wait timer is reset to min_delay.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.reinitialise">
<span class="sig-name descname"><span class="pre">reinitialise</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">client_id</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">clean_session</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">userdata</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.reinitialise" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.socket">
<span class="sig-name descname"><span class="pre">socket</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">SocketLike</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.socket" title="Link to this definition">¶</a></dt>
<dd><p>Return the socket or ssl object for this client.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.subscribe">
<span class="sig-name descname"><span class="pre">subscribe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">SubscribeOptions</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">SubscribeOptions</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">options</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">SubscribeOptions</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.subscribe" title="Link to this definition">¶</a></dt>
<dd><p>Subscribe the client to one or more topics.</p>
<p>This function may be called in three different ways (and a further three for MQTT v5.0):</p>
<section id="simple-string-and-integer">
<h3>Simple string and integer<a class="headerlink" href="#simple-string-and-integer" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe(“my/topic”, 2)</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A string specifying the subscription topic to subscribe to.</p>
</dd>
<dt class="field-even">qos<span class="colon">:</span></dt>
<dd class="field-even"><p>The desired quality of service level for the subscription.
Defaults to 0.</p>
</dd>
<dt class="field-odd">options and properties<span class="colon">:</span></dt>
<dd class="field-odd"><p>Not used.</p>
</dd>
</dl>
</section>
<section id="simple-string-and-subscribe-options-mqtt-v5-0-only">
<h3>Simple string and subscribe options (MQTT v5.0 only)<a class="headerlink" href="#simple-string-and-subscribe-options-mqtt-v5-0-only" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe(“my/topic”, options=SubscribeOptions(qos=2))</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A string specifying the subscription topic to subscribe to.</p>
</dd>
<dt class="field-even">qos<span class="colon">:</span></dt>
<dd class="field-even"><p>Not used.</p>
</dd>
<dt class="field-odd">options<span class="colon">:</span></dt>
<dd class="field-odd"><p>The MQTT v5.0 subscribe options.</p>
</dd>
<dt class="field-even">properties<span class="colon">:</span></dt>
<dd class="field-even"><p>a Properties instance setting the MQTT v5.0 properties
to be included. Optional - if not set, no properties are sent.</p>
</dd>
</dl>
</section>
<section id="string-and-integer-tuple">
<h3>String and integer tuple<a class="headerlink" href="#string-and-integer-tuple" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe((“my/topic”, 1))</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A tuple of (topic, qos). Both topic and qos must be present in
the tuple.</p>
</dd>
<dt class="field-even">qos and options<span class="colon">:</span></dt>
<dd class="field-even"><p>Not used.</p>
</dd>
<dt class="field-odd">properties<span class="colon">:</span></dt>
<dd class="field-odd"><p>Only used for MQTT v5.0.  A Properties instance setting the
MQTT v5.0 properties. Optional - if not set, no properties are sent.</p>
</dd>
</dl>
</section>
<section id="string-and-subscribe-options-tuple-mqtt-v5-0-only">
<h3>String and subscribe options tuple (MQTT v5.0 only)<a class="headerlink" href="#string-and-subscribe-options-tuple-mqtt-v5-0-only" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe((“my/topic”, SubscribeOptions(qos=1)))</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A tuple of (topic, SubscribeOptions). Both topic and subscribe
options must be present in the tuple.</p>
</dd>
<dt class="field-even">qos and options<span class="colon">:</span></dt>
<dd class="field-even"><p>Not used.</p>
</dd>
<dt class="field-odd">properties<span class="colon">:</span></dt>
<dd class="field-odd"><p>a Properties instance setting the MQTT v5.0 properties
to be included. Optional - if not set, no properties are sent.</p>
</dd>
</dl>
</section>
<section id="list-of-string-and-integer-tuples">
<h3>List of string and integer tuples<a class="headerlink" href="#list-of-string-and-integer-tuples" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe([(“my/topic”, 0), (“another/topic”, 2)])</p>
<p>This allows multiple topic subscriptions in a single SUBSCRIPTION
command, which is more efficient than using multiple calls to
subscribe().</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A list of tuple of format (topic, qos). Both topic and qos must
be present in all of the tuples.</p>
</dd>
<dt class="field-even">qos, options and properties<span class="colon">:</span></dt>
<dd class="field-even"><p>Not used.</p>
</dd>
</dl>
</section>
<section id="list-of-string-and-subscribe-option-tuples-mqtt-v5-0-only">
<h3>List of string and subscribe option tuples (MQTT v5.0 only)<a class="headerlink" href="#list-of-string-and-subscribe-option-tuples-mqtt-v5-0-only" title="Link to this heading">¶</a></h3>
<p>e.g. subscribe([(“my/topic”, SubscribeOptions(qos=0), (“another/topic”, SubscribeOptions(qos=2)])</p>
<p>This allows multiple topic subscriptions in a single SUBSCRIPTION
command, which is more efficient than using multiple calls to
subscribe().</p>
<dl class="field-list simple">
<dt class="field-odd">topic<span class="colon">:</span></dt>
<dd class="field-odd"><p>A list of tuple of format (topic, SubscribeOptions). Both topic and subscribe
options must be present in all of the tuples.</p>
</dd>
<dt class="field-even">qos and options<span class="colon">:</span></dt>
<dd class="field-even"><p>Not used.</p>
</dd>
<dt class="field-odd">properties<span class="colon">:</span></dt>
<dd class="field-odd"><p>a Properties instance setting the MQTT v5.0 properties
to be included. Optional - if not set, no properties are sent.</p>
</dd>
</dl>
<p>The function returns a tuple (result, mid), where result is
MQTT_ERR_SUCCESS to indicate success or (MQTT_ERR_NO_CONN, None) if the
client is not currently connected.  mid is the message ID for the
subscribe request. The mid value can be used to track the subscribe
request by checking against the mid argument in the on_subscribe()
callback if it is defined.</p>
<p>Raises a ValueError if qos is not 0, 1 or 2, or if topic is None or has
zero string length, or if topic is not a string, tuple or list.</p>
</section>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.tls_insecure_set">
<span class="sig-name descname"><span class="pre">tls_insecure_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.tls_insecure_set" title="Link to this definition">¶</a></dt>
<dd><p>Configure verification of the server hostname in the server certificate.</p>
<p>If value is set to true, it is impossible to guarantee that the host
you are connecting to is not impersonating your server. This can be
useful in initial server testing, but makes it possible for a malicious
third party to impersonate your server through DNS spoofing, for
example.</p>
<p>Do not use this function in a real system. Setting value to true means
there is no point using encryption.</p>
<p>Must be called before <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a> and after either <a class="reference internal" href="#paho.mqtt.client.Client.tls_set" title="paho.mqtt.client.Client.tls_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">tls_set()</span></code></a> or
<a class="reference internal" href="#paho.mqtt.client.Client.tls_set_context" title="paho.mqtt.client.Client.tls_set_context"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">tls_set_context()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.tls_set">
<span class="sig-name descname"><span class="pre">tls_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">ca_certs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">certfile</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keyfile</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cert_reqs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">VerifyMode</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tls_version</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ciphers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">keyfile_password</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alpn_protocols</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.tls_set" title="Link to this definition">¶</a></dt>
<dd><p>Configure network encryption and authentication options. Enables SSL/TLS support.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ca_certs</strong> (<em>str</em>) – <p>a string path to the Certificate Authority certificate files
that are to be treated as trusted by this client. If this is the only
option given then the client will operate in a similar manner to a web
browser. That is to say it will require the broker to have a
certificate signed by the Certificate Authorities in ca_certs and will
communicate using TLS v1,2, but will not attempt any form of
authentication. This provides basic network encryption but may not be
sufficient depending on how the broker is configured.</p>
<p>By default, on Python 2.7.9+ or 3.4+, the default certification
authority of the system is used. On older Python version this parameter
is mandatory.</p>
</p></li>
<li><p><strong>certfile</strong> (<em>str</em>) – PEM encoded client certificate filename. Used with
keyfile for client TLS based authentication. Support for this feature is
broker dependent. Note that if the files in encrypted and needs a password to
decrypt it, then this can be passed using the keyfile_password argument - you
should take precautions to ensure that your password is
not hard coded into your program by loading the password from a file
for example. If you do not provide keyfile_password, the password will
be requested to be typed in at a terminal window.</p></li>
<li><p><strong>keyfile</strong> (<em>str</em>) – PEM encoded client private keys filename. Used with
certfile for client TLS based authentication. Support for this feature is
broker dependent. Note that if the files in encrypted and needs a password to
decrypt it, then this can be passed using the keyfile_password argument - you
should take precautions to ensure that your password is
not hard coded into your program by loading the password from a file
for example. If you do not provide keyfile_password, the password will
be requested to be typed in at a terminal window.</p></li>
<li><p><strong>cert_reqs</strong> – the certificate requirements that the client imposes
on the broker to be changed. By default this is ssl.CERT_REQUIRED,
which means that the broker must provide a certificate. See the ssl
pydoc for more information on this parameter.</p></li>
<li><p><strong>tls_version</strong> – the version of the SSL/TLS protocol used to be
specified. By default TLS v1.2 is used. Previous versions are allowed
but not recommended due to possible security problems.</p></li>
<li><p><strong>ciphers</strong> (<em>str</em>) – encryption ciphers that are allowed
for this connection, or None to use the defaults. See the ssl pydoc for
more information.</p></li>
</ul>
</dd>
</dl>
<p>Must be called before <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.connect_async" title="paho.mqtt.client.Client.connect_async"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_async()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.connect_srv" title="paho.mqtt.client.Client.connect_srv"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_srv()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.tls_set_context">
<span class="sig-name descname"><span class="pre">tls_set_context</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">context</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">SSLContext</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.tls_set_context" title="Link to this definition">¶</a></dt>
<dd><p>Configure network encryption and authentication context. Enables SSL/TLS support.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>context</strong> – an ssl.SSLContext object. By default this is given by
<code class="docutils literal notranslate"><span class="pre">ssl.create_default_context()</span></code>, if available.</p>
</dd>
</dl>
<p>Must be called before <a class="reference internal" href="#paho.mqtt.client.Client.connect" title="paho.mqtt.client.Client.connect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect()</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.connect_async" title="paho.mqtt.client.Client.connect_async"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_async()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.connect_srv" title="paho.mqtt.client.Client.connect_srv"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">connect_srv()</span></code></a>.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.transport">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">transport</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Literal</span><span class="p"><span class="pre">[</span></span><span class="s"><span class="pre">'tcp'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'websockets'</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="s"><span class="pre">'unix'</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#paho.mqtt.client.Client.transport" title="Link to this definition">¶</a></dt>
<dd><p>Transport method used for the connection (“tcp” or “websockets”).</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.unsubscribe">
<span class="sig-name descname"><span class="pre">unsubscribe</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">list</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">tuple</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.unsubscribe" title="Link to this definition">¶</a></dt>
<dd><p>Unsubscribe the client from one or more topics.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>topic</strong> – A single string, or list of strings that are the subscription
topics to unsubscribe from.</p></li>
<li><p><strong>properties</strong> – (MQTT v5.0 only) a Properties instance setting the MQTT v5.0 properties
to be included. Optional - if not set, no properties are sent.</p></li>
</ul>
</dd>
</dl>
<p>Returns a tuple (result, mid), where result is MQTT_ERR_SUCCESS
to indicate success or (MQTT_ERR_NO_CONN, None) if the client is not
currently connected.
mid is the message ID for the unsubscribe request. The mid value can be
used to track the unsubscribe request by checking against the mid
argument in the on_unsubscribe() callback if it is defined.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>ValueError</strong> – if topic is None or has zero string length, or is
not a string or list.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.user_data_get">
<span class="sig-name descname"><span class="pre">user_data_get</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Any</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.user_data_get" title="Link to this definition">¶</a></dt>
<dd><p>Get the user data variable passed to callbacks. May be any data type.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.user_data_set">
<span class="sig-name descname"><span class="pre">user_data_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">userdata</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Any</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.user_data_set" title="Link to this definition">¶</a></dt>
<dd><p>Set the user data variable passed to callbacks. May be any data type.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.username">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">username</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.username" title="Link to this definition">¶</a></dt>
<dd><p>The username used to connect to the MQTT broker, or None if no username is used.</p>
<p>This property may not be changed if the connection is already open.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.username_pw_set">
<span class="sig-name descname"><span class="pre">username_pw_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">username</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">password</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.username_pw_set" title="Link to this definition">¶</a></dt>
<dd><p>Set a username and optionally a password for broker authentication.</p>
<p>Must be called before connect() to have any effect.
Requires a broker that supports MQTT v3.1 or more.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>username</strong> (<em>str</em>) – The username to authenticate with. Need have no relationship to the client id. Must be str
[MQTT-3.1.3-11].
Set to None to reset client back to not using username/password for broker authentication.</p></li>
<li><p><strong>password</strong> (<em>str</em>) – The password to authenticate with. Optional, set to None if not required. If it is str, then it
will be encoded as UTF-8.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.want_write">
<span class="sig-name descname"><span class="pre">want_write</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.want_write" title="Link to this definition">¶</a></dt>
<dd><p>Call to determine if there is network data waiting to be written.
Useful if you are calling select() yourself rather than using <a class="reference internal" href="#paho.mqtt.client.Client.loop" title="paho.mqtt.client.Client.loop"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop()</span></code></a>, <a class="reference internal" href="#paho.mqtt.client.Client.loop_start" title="paho.mqtt.client.Client.loop_start"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_start()</span></code></a> or <a class="reference internal" href="#paho.mqtt.client.Client.loop_forever" title="paho.mqtt.client.Client.loop_forever"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">loop_forever()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.will_clear">
<span class="sig-name descname"><span class="pre">will_clear</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.will_clear" title="Link to this definition">¶</a></dt>
<dd><p>Removes a will that was previously configured with <a class="reference internal" href="#paho.mqtt.client.Client.will_set" title="paho.mqtt.client.Client.will_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">will_set()</span></code></a>.</p>
<p>Must be called before connect() to have any effect.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.will_payload">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">will_payload</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bytes</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.will_payload" title="Link to this definition">¶</a></dt>
<dd><p>The payload for the will message that is sent when disconnecting unexpectedly. None if a will shall not be sent.</p>
<p>This property is read-only. Use <a class="reference internal" href="#paho.mqtt.client.Client.will_set" title="paho.mqtt.client.Client.will_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">will_set()</span></code></a> to change its value.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.will_set">
<span class="sig-name descname"><span class="pre">will_set</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">payload</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">bytes</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">bytearray</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">qos</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">retain</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">properties</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.will_set" title="Link to this definition">¶</a></dt>
<dd><p>Set a Will to be sent by the broker in case the client disconnects unexpectedly.</p>
<p>This must be called before connect() to have any effect.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>topic</strong> (<em>str</em>) – The topic that the will message should be published on.</p></li>
<li><p><strong>payload</strong> – The message to send as a will. If not given, or set to None a
zero length message will be used as the will. Passing an int or float
will result in the payload being converted to a string representing
that number. If you wish to send a true int/float, use struct.pack() to
create the payload you require.</p></li>
<li><p><strong>qos</strong> (<em>int</em>) – The quality of service level to use for the will.</p></li>
<li><p><strong>retain</strong> (<em>bool</em>) – If set to true, the will message will be set as the “last known
good”/retained message for the topic.</p></li>
<li><p><strong>properties</strong> (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><em>Properties</em></a>) – (MQTT v5.0 only) the MQTT v5.0 properties
to be included with the will message. Optional - if not set, no properties are sent.</p></li>
</ul>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><p><strong>ValueError</strong> – if qos is not 0, 1 or 2, or if topic is None or has
zero string length.</p>
</dd>
</dl>
<p>See <a class="reference internal" href="#paho.mqtt.client.Client.will_clear" title="paho.mqtt.client.Client.will_clear"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">will_clear</span></code></a> to clear will. Note that will are NOT send if the client disconnect cleanly
for example by calling <a class="reference internal" href="#paho.mqtt.client.Client.disconnect" title="paho.mqtt.client.Client.disconnect"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">disconnect()</span></code></a>.</p>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.will_topic">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">will_topic</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.Client.will_topic" title="Link to this definition">¶</a></dt>
<dd><p>The topic name a will message is sent to when disconnecting unexpectedly. None if a will shall not be sent.</p>
<p>This property is read-only. Use <a class="reference internal" href="#paho.mqtt.client.Client.will_set" title="paho.mqtt.client.Client.will_set"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">will_set()</span></code></a> to change its value.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.Client.ws_set_options">
<span class="sig-name descname"><span class="pre">ws_set_options</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">path</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'/mqtt'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">headers</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">Dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">str</span><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.Client.ws_set_options" title="Link to this definition">¶</a></dt>
<dd><p>Set the path and headers for a websocket connection</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>path</strong> (<em>str</em>) – a string starting with / which should be the endpoint of the
mqtt connection on the remote server</p></li>
<li><p><strong>headers</strong> – can be either a dict or a callable object. If it is a dict then
the extra items in the dict are added to the websocket headers. If it is
a callable, then the default websocket headers are passed into this
function and the result is used as the new headers.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</section>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="paho.mqtt.client.ConnectFlags">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">ConnectFlags</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">session_present</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paho.mqtt.client.ConnectFlags" title="Link to this definition">¶</a></dt>
<dd><p>Contains additional information passed to <a class="reference internal" href="#paho.mqtt.client.Client.on_connect" title="paho.mqtt.client.Client.on_connect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_connect</span></code></a> callback</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.ConnectFlags.session_present">
<span class="sig-name descname"><span class="pre">session_present</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#paho.mqtt.client.ConnectFlags.session_present" title="Link to this definition">¶</a></dt>
<dd><p>this flag is useful for clients that are
using clean session set to False only (MQTTv3) or clean_start = False (MQTTv5).
In that case, if client  that reconnects to a broker that it has previously
connected to, this flag indicates whether the broker still has the
session information for the client. If true, the session still exists.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="paho.mqtt.client.DisconnectFlags">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">DisconnectFlags</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">is_disconnect_packet_from_server</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bool</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paho.mqtt.client.DisconnectFlags" title="Link to this definition">¶</a></dt>
<dd><p>Contains additional information passed to <a class="reference internal" href="#paho.mqtt.client.Client.on_disconnect" title="paho.mqtt.client.Client.on_disconnect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_disconnect</span></code></a> callback</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.DisconnectFlags.is_disconnect_packet_from_server">
<span class="sig-name descname"><span class="pre">is_disconnect_packet_from_server</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">bool</span></em><a class="headerlink" href="#paho.mqtt.client.DisconnectFlags.is_disconnect_packet_from_server" title="Link to this definition">¶</a></dt>
<dd><p>tells whether this on_disconnect call is the result
of receiving an DISCONNECT packet from the broker or if the on_disconnect is only
generated by the client library.
When true, the reason code is generated by the broker.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">MQTTMessage</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mid</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">bytes</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">b''</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage" title="Link to this definition">¶</a></dt>
<dd><p>This is a class that describes an incoming message. It is
passed to the <a class="reference internal" href="#paho.mqtt.client.Client.on_message" title="paho.mqtt.client.Client.on_message"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_message</span></code></a> callback as the message parameter.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.dup">
<span class="sig-name descname"><span class="pre">dup</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.dup" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.info">
<span class="sig-name descname"><span class="pre">info</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.info" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.mid">
<span class="sig-name descname"><span class="pre">mid</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.mid" title="Link to this definition">¶</a></dt>
<dd><p>The message id (int).</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.payload">
<span class="sig-name descname"><span class="pre">payload</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.payload" title="Link to this definition">¶</a></dt>
<dd><p>the message payload (bytes)</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.properties">
<span class="sig-name descname"><span class="pre">properties</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><span class="pre">Properties</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></em><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.properties" title="Link to this definition">¶</a></dt>
<dd><p>In MQTT v5.0, the properties associated with the message. (<a class="reference internal" href="types.html#paho.mqtt.properties.Properties" title="paho.mqtt.properties.Properties"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Properties</span></code></a>)</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.qos">
<span class="sig-name descname"><span class="pre">qos</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.qos" title="Link to this definition">¶</a></dt>
<dd><p>The message Quality of Service (0, 1 or 2).</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.retain">
<span class="sig-name descname"><span class="pre">retain</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.retain" title="Link to this definition">¶</a></dt>
<dd><p>If true, the message is a retained message and not fresh.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.state">
<span class="sig-name descname"><span class="pre">state</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.state" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.timestamp">
<span class="sig-name descname"><span class="pre">timestamp</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.timestamp" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessage.topic">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">topic</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">str</span></em><a class="headerlink" href="#paho.mqtt.client.MQTTMessage.topic" title="Link to this definition">¶</a></dt>
<dd><p>topic that the message was published on.</p>
<p>This property is read-only.</p>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">MQTTMessageInfo</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mid</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo" title="Link to this definition">¶</a></dt>
<dd><p>This is a class returned from <a class="reference internal" href="#paho.mqtt.client.Client.publish" title="paho.mqtt.client.Client.publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">Client.publish()</span></code></a> and can be used to find
out the mid of the message that was published, and to determine whether the
message has been published, and/or wait until it is published.</p>
<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo.is_published">
<span class="sig-name descname"><span class="pre">is_published</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo.is_published" title="Link to this definition">¶</a></dt>
<dd><p>Returns True if the message associated with this object has been
published, else returns False.</p>
<p>To wait for this to become true, look at <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish" title="paho.mqtt.client.MQTTMessageInfo.wait_for_publish"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">wait_for_publish</span></code></a>.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo.mid">
<span class="sig-name descname"><span class="pre">mid</span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo.mid" title="Link to this definition">¶</a></dt>
<dd><p>The message Id (int)</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo.next">
<span class="sig-name descname"><span class="pre">next</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span></span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo.next" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo.rc">
<span class="sig-name descname"><span class="pre">rc</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></em><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo.rc" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><code class="xref any py py-class docutils literal notranslate"><span class="pre">MQTTErrorCode</span></code></a> that give status for this message.
This value could change until the message <a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.is_published" title="paho.mqtt.client.MQTTMessageInfo.is_published"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">is_published</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="paho.mqtt.client.MQTTMessageInfo.wait_for_publish">
<span class="sig-name descname"><span class="pre">wait_for_publish</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">timeout</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">None</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">None</span></span></span><a class="headerlink" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish" title="Link to this definition">¶</a></dt>
<dd><p>Block until the message associated with this object is published, or
until the timeout occurs. If timeout is None, this will never time out.
Set timeout to a positive number of seconds, e.g. 1.2, to enable the
timeout.</p>
<dl class="field-list simple">
<dt class="field-odd">Raises<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ValueError</strong> – if the message was not queued due to the outgoing
queue being full.</p></li>
<li><p><strong>RuntimeError</strong> – if the message was not published for another
reason.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</dd></dl>

<dl class="py exception">
<dt class="sig sig-object py" id="paho.mqtt.client.WebsocketConnectionError">
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">WebsocketConnectionError</span></span><a class="headerlink" href="#paho.mqtt.client.WebsocketConnectionError" title="Link to this definition">¶</a></dt>
<dd><p>WebsocketConnectionError is a subclass of ConnectionError.</p>
<p>It’s raised when unable to perform the Websocket handshake.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="paho.mqtt.client.connack_string">
<span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">connack_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connack_code</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#paho.mqtt.client.connack_string" title="Link to this definition">¶</a></dt>
<dd><p>Return the string associated with a CONNACK result or CONNACK reason code.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="paho.mqtt.client.convert_connack_rc_to_reason_code">
<span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">convert_connack_rc_to_reason_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">connack_code</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.enums.ConnackCode" title="paho.mqtt.enums.ConnackCode"><span class="pre">ConnackCode</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.convert_connack_rc_to_reason_code" title="Link to this definition">¶</a></dt>
<dd><p>Convert a MQTTv3 / MQTTv3.1.1 connack result to <a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><code class="xref any py py-class docutils literal notranslate"><span class="pre">ReasonCode</span></code></a>.</p>
<p>This is used in <a class="reference internal" href="#paho.mqtt.client.Client.on_connect" title="paho.mqtt.client.Client.on_connect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_connect</span></code></a> callback to have a consistent API.</p>
<p>Be careful that the numeric value isn’t the same, for example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">ConnackCode</span><span class="o">.</span><span class="n">CONNACK_REFUSED_SERVER_UNAVAILABLE</span> <span class="o">==</span> <span class="mi">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">convert_connack_rc_to_reason_code</span><span class="p">(</span><span class="n">ConnackCode</span><span class="o">.</span><span class="n">CONNACK_REFUSED_SERVER_UNAVAILABLE</span><span class="p">)</span> <span class="o">==</span> <span class="mi">136</span>
</pre></div>
</div>
<p>It’s recommended to compare by names</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">code_to_test</span> <span class="o">=</span> <span class="n">ReasonCode</span><span class="p">(</span><span class="n">PacketTypes</span><span class="o">.</span><span class="n">CONNACK</span><span class="p">,</span> <span class="s2">&quot;Server unavailable&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">convert_connack_rc_to_reason_code</span><span class="p">(</span><span class="n">ConnackCode</span><span class="o">.</span><span class="n">CONNACK_REFUSED_SERVER_UNAVAILABLE</span><span class="p">)</span> <span class="o">==</span> <span class="n">code_to_test</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="paho.mqtt.client.convert_disconnect_error_code_to_reason_code">
<span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">convert_disconnect_error_code_to_reason_code</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rc</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="types.html#paho.mqtt.reasoncodes.ReasonCode" title="paho.mqtt.reasoncodes.ReasonCode"><span class="pre">ReasonCode</span></a></span></span><a class="headerlink" href="#paho.mqtt.client.convert_disconnect_error_code_to_reason_code" title="Link to this definition">¶</a></dt>
<dd><p>Convert an MQTTErrorCode to Reason code.</p>
<p>This is used in <a class="reference internal" href="#paho.mqtt.client.Client.on_disconnect" title="paho.mqtt.client.Client.on_disconnect"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">on_disconnect</span></code></a> callback to have a consistent API.</p>
<p>Be careful that the numeric value isn’t the same, for example:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">MQTTErrorCode</span><span class="o">.</span><span class="n">MQTT_ERR_PROTOCOL</span> <span class="o">==</span> <span class="mi">2</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">convert_disconnect_error_code_to_reason_code</span><span class="p">(</span><span class="n">MQTTErrorCode</span><span class="o">.</span><span class="n">MQTT_ERR_PROTOCOL</span><span class="p">)</span> <span class="o">==</span> <span class="mi">130</span>
</pre></div>
</div>
<p>It’s recommended to compare by names</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">code_to_test</span> <span class="o">=</span> <span class="n">ReasonCode</span><span class="p">(</span><span class="n">PacketTypes</span><span class="o">.</span><span class="n">DISCONNECT</span><span class="p">,</span> <span class="s2">&quot;Protocol error&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">convert_disconnect_error_code_to_reason_code</span><span class="p">(</span><span class="n">MQTTErrorCode</span><span class="o">.</span><span class="n">MQTT_ERR_PROTOCOL</span><span class="p">)</span> <span class="o">==</span> <span class="n">code_to_test</span>
</pre></div>
</div>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="paho.mqtt.client.error_string">
<span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">error_string</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mqtt_errno</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="types.html#paho.mqtt.enums.MQTTErrorCode" title="paho.mqtt.enums.MQTTErrorCode"><span class="pre">MQTTErrorCode</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">str</span></span></span><a class="headerlink" href="#paho.mqtt.client.error_string" title="Link to this definition">¶</a></dt>
<dd><p>Return the error string associated with an mqtt error number.</p>
</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="paho.mqtt.client.topic_matches_sub">
<span class="sig-prename descclassname"><span class="pre">paho.mqtt.client.</span></span><span class="sig-name descname"><span class="pre">topic_matches_sub</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sub</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">topic</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">str</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#paho.mqtt.client.topic_matches_sub" title="Link to this definition">¶</a></dt>
<dd><p>Check whether a topic matches a subscription.</p>
<p>For example:</p>
<ul class="simple">
<li><p>Topic “foo/bar” would match the subscription “foo/#” or “+/bar”</p></li>
<li><p>Topic “non/matching” would not match the subscription “non/+/+”</p></li>
</ul>
</dd></dl>

</section>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">Eclipse paho-mqtt</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">client module</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.Client"><code class="docutils literal notranslate"><span class="pre">Client</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.ack"><code class="docutils literal notranslate"><span class="pre">Client.ack()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.callback_api_version"><code class="docutils literal notranslate"><span class="pre">Client.callback_api_version</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.connect"><code class="docutils literal notranslate"><span class="pre">Client.connect()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.connect_async"><code class="docutils literal notranslate"><span class="pre">Client.connect_async()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.connect_srv"><code class="docutils literal notranslate"><span class="pre">Client.connect_srv()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.connect_timeout"><code class="docutils literal notranslate"><span class="pre">Client.connect_timeout</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.disable_logger"><code class="docutils literal notranslate"><span class="pre">Client.disable_logger()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.disconnect"><code class="docutils literal notranslate"><span class="pre">Client.disconnect()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.enable_bridge_mode"><code class="docutils literal notranslate"><span class="pre">Client.enable_bridge_mode()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.enable_logger"><code class="docutils literal notranslate"><span class="pre">Client.enable_logger()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.host"><code class="docutils literal notranslate"><span class="pre">Client.host</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.is_connected"><code class="docutils literal notranslate"><span class="pre">Client.is_connected()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.keepalive"><code class="docutils literal notranslate"><span class="pre">Client.keepalive</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.logger"><code class="docutils literal notranslate"><span class="pre">Client.logger</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop"><code class="docutils literal notranslate"><span class="pre">Client.loop()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_forever"><code class="docutils literal notranslate"><span class="pre">Client.loop_forever()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_misc"><code class="docutils literal notranslate"><span class="pre">Client.loop_misc()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_read"><code class="docutils literal notranslate"><span class="pre">Client.loop_read()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_start"><code class="docutils literal notranslate"><span class="pre">Client.loop_start()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_stop"><code class="docutils literal notranslate"><span class="pre">Client.loop_stop()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.loop_write"><code class="docutils literal notranslate"><span class="pre">Client.loop_write()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.manual_ack_set"><code class="docutils literal notranslate"><span class="pre">Client.manual_ack_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.max_inflight_messages"><code class="docutils literal notranslate"><span class="pre">Client.max_inflight_messages</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.max_inflight_messages_set"><code class="docutils literal notranslate"><span class="pre">Client.max_inflight_messages_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.max_queued_messages"><code class="docutils literal notranslate"><span class="pre">Client.max_queued_messages</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.max_queued_messages_set"><code class="docutils literal notranslate"><span class="pre">Client.max_queued_messages_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.message_callback_add"><code class="docutils literal notranslate"><span class="pre">Client.message_callback_add()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.message_callback_remove"><code class="docutils literal notranslate"><span class="pre">Client.message_callback_remove()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_connect"><code class="docutils literal notranslate"><span class="pre">Client.on_connect</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_connect_fail"><code class="docutils literal notranslate"><span class="pre">Client.on_connect_fail</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_disconnect"><code class="docutils literal notranslate"><span class="pre">Client.on_disconnect</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_log"><code class="docutils literal notranslate"><span class="pre">Client.on_log</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_message"><code class="docutils literal notranslate"><span class="pre">Client.on_message</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_pre_connect"><code class="docutils literal notranslate"><span class="pre">Client.on_pre_connect</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_publish"><code class="docutils literal notranslate"><span class="pre">Client.on_publish</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_socket_close"><code class="docutils literal notranslate"><span class="pre">Client.on_socket_close</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_socket_open"><code class="docutils literal notranslate"><span class="pre">Client.on_socket_open</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_socket_register_write"><code class="docutils literal notranslate"><span class="pre">Client.on_socket_register_write</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_socket_unregister_write"><code class="docutils literal notranslate"><span class="pre">Client.on_socket_unregister_write</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_subscribe"><code class="docutils literal notranslate"><span class="pre">Client.on_subscribe</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.on_unsubscribe"><code class="docutils literal notranslate"><span class="pre">Client.on_unsubscribe</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.password"><code class="docutils literal notranslate"><span class="pre">Client.password</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.port"><code class="docutils literal notranslate"><span class="pre">Client.port</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.protocol"><code class="docutils literal notranslate"><span class="pre">Client.protocol</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.proxy_set"><code class="docutils literal notranslate"><span class="pre">Client.proxy_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.publish"><code class="docutils literal notranslate"><span class="pre">Client.publish()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.reconnect"><code class="docutils literal notranslate"><span class="pre">Client.reconnect()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.reconnect_delay_set"><code class="docutils literal notranslate"><span class="pre">Client.reconnect_delay_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.reinitialise"><code class="docutils literal notranslate"><span class="pre">Client.reinitialise()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.socket"><code class="docutils literal notranslate"><span class="pre">Client.socket()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.subscribe"><code class="docutils literal notranslate"><span class="pre">Client.subscribe()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.tls_insecure_set"><code class="docutils literal notranslate"><span class="pre">Client.tls_insecure_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.tls_set"><code class="docutils literal notranslate"><span class="pre">Client.tls_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.tls_set_context"><code class="docutils literal notranslate"><span class="pre">Client.tls_set_context()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.transport"><code class="docutils literal notranslate"><span class="pre">Client.transport</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.unsubscribe"><code class="docutils literal notranslate"><span class="pre">Client.unsubscribe()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.user_data_get"><code class="docutils literal notranslate"><span class="pre">Client.user_data_get()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.user_data_set"><code class="docutils literal notranslate"><span class="pre">Client.user_data_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.username"><code class="docutils literal notranslate"><span class="pre">Client.username</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.username_pw_set"><code class="docutils literal notranslate"><span class="pre">Client.username_pw_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.want_write"><code class="docutils literal notranslate"><span class="pre">Client.want_write()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.will_clear"><code class="docutils literal notranslate"><span class="pre">Client.will_clear()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.will_payload"><code class="docutils literal notranslate"><span class="pre">Client.will_payload</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.will_set"><code class="docutils literal notranslate"><span class="pre">Client.will_set()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.will_topic"><code class="docutils literal notranslate"><span class="pre">Client.will_topic</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.Client.ws_set_options"><code class="docutils literal notranslate"><span class="pre">Client.ws_set_options()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.ConnectFlags"><code class="docutils literal notranslate"><span class="pre">ConnectFlags</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.ConnectFlags.session_present"><code class="docutils literal notranslate"><span class="pre">ConnectFlags.session_present</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.DisconnectFlags"><code class="docutils literal notranslate"><span class="pre">DisconnectFlags</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.DisconnectFlags.is_disconnect_packet_from_server"><code class="docutils literal notranslate"><span class="pre">DisconnectFlags.is_disconnect_packet_from_server</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage"><code class="docutils literal notranslate"><span class="pre">MQTTMessage</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.dup"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.dup</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.info"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.info</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.mid"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.mid</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.payload"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.payload</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.properties"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.properties</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.qos"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.qos</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.retain"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.retain</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.state"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.state</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.timestamp"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.timestamp</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessage.topic"><code class="docutils literal notranslate"><span class="pre">MQTTMessage.topic</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.is_published"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo.is_published()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.mid"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo.mid</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.next"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo.next()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.rc"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo.rc</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="#paho.mqtt.client.MQTTMessageInfo.wait_for_publish"><code class="docutils literal notranslate"><span class="pre">MQTTMessageInfo.wait_for_publish()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.WebsocketConnectionError"><code class="docutils literal notranslate"><span class="pre">WebsocketConnectionError</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.connack_string"><code class="docutils literal notranslate"><span class="pre">connack_string()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.convert_connack_rc_to_reason_code"><code class="docutils literal notranslate"><span class="pre">convert_connack_rc_to_reason_code()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.convert_disconnect_error_code_to_reason_code"><code class="docutils literal notranslate"><span class="pre">convert_disconnect_error_code_to_reason_code()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.error_string"><code class="docutils literal notranslate"><span class="pre">error_string()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="#paho.mqtt.client.topic_matches_sub"><code class="docutils literal notranslate"><span class="pre">topic_matches_sub()</span></code></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="helpers.html">helpers</a></li>
<li class="toctree-l1"><a class="reference internal" href="types.html">Types and enums</a></li>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="migrations.html">Migrations</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="index.html" title="previous chapter">Eclipse Paho™ MQTT Python Client</a></li>
      <li>Next: <a href="helpers.html" title="next chapter">helpers</a></li>
  </ul></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &#169;2024, Eclipse.
      
      |
      Powered by <a href="https://www.sphinx-doc.org/">Sphinx 7.3.7</a>
      &amp; <a href="https://alabaster.readthedocs.io">Alabaster 0.7.16</a>
      
      |
      <a href="_sources/client.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>